<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>flex-实战</title>
</head>

<style>
    /* 头部标签置顶并固定 */
    .search-index {
        position: fixed;
        top: 0;
        
        /* 注意居中的写法 */
        left: 50% ;
        transform: translateX(-50%);

        height: 40px;
        width: 100%;
        max-width: 640px;
        background-color: pink;
    }
</style>
<body>
    <div class="search-index">

    </div>

</body>
</html>